<?php
	$categories		= $this->mod_lib->load_all('categories', '', array('status'=>1, 'level'=>1, 'order !='=>""), '', '', array('order'=>'ASC'));	
?>
<?php $i=1; foreach ($categories as $c1){?>
	<?php
		if (!empty($province_id) && isset($province_id))
		{
			$total_product	= $this->mod_lib->join('products', 'products.id, products.title, products.image', array('products.status'=>1, 'categories.status'=>1, 'products.cat_1_id'=>$c1['id'], 'province_id'=>$province_id), array('categories'=>'categories.id = products.cat_1_id'), '', '', array('products.updatedate'=>'DESC'));
			$list_product	= $this->mod_lib->join('products', 'products.id, products.title, products.image', array('products.status'=>1, 'categories.status'=>1, 'products.cat_1_id'=>$c1['id'], 'province_id'=>$province_id), array('categories'=>'categories.id = products.cat_1_id'), 5, '', array('products.updatedate'=>'DESC'));
		}
		else
		{
			$total_product	= $this->mod_lib->join('products', 'products.id, products.title, products.image', array('products.status'=>1, 'categories.status'=>1, 'products.cat_1_id'=>$c1['id']), array('categories'=>'categories.id = products.cat_1_id'), '', '', array('products.updatedate'=>'DESC'));
			$list_product	= $this->mod_lib->join('products', 'products.id, products.title, products.image', array('products.status'=>1, 'categories.status'=>1, 'products.cat_1_id'=>$c1['id']), array('categories'=>'categories.id = products.cat_1_id'), 5, '', array('products.updatedate'=>'DESC'));
		}
	?>
	<div class="col_335">
    	<div class="title">
    		<?php if (!empty($province_name) && isset($province_name)){?>
        		<a href="<?php echo base_url().$province_name.'/'.url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'.html'?>"><?php echo $c1['name']?> (<?php echo number_format(count($total_product), 0, '.', '')?>)</a>
        	<?php }else{?>
        		<a href="<?php echo base_url().url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'.html'?>"><?php echo $c1['name']?> (<?php echo number_format(count($total_product), 0, '.', '')?>)</a>
        	<?php }?>            
        </div>
        
        <div class="list_l2">
        	<ul>
        		<?php $categories2		= $this->mod_lib->load_all('categories', '', array('status'=>1, 'level'=>2), '', '', array('order'=>'ASC'));?>
		        <?php $i2=1; foreach ($categories2 as $c2){?>
		        	<?php if ($c2['cat_id'] == $c1['id']){?>
		                <li>
		                	<?php if (!empty($province_name) && isset($province_name)){?>
		                		<a href="<?php echo base_url().$province_name.'/'.url_title(utf8_to_ascii($c2['name'])).'-'.url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'-'.$c2['id'].'.html'?>"><strong><?php echo $c2['name']?></strong></a>
		                	<?php }else{?>
		                		<a href="<?php echo base_url().url_title(utf8_to_ascii($c2['name'])).'-'.url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'-'.$c2['id'].'.html'?>"><strong><?php echo $c2['name']?></strong></a>
		                	<?php }?>
		                	<?php $categories3		= $this->mod_lib->load_all('categories', '', array('status'=>1, 'level'=>3), '', '', array('order'=>'ASC'));?>
		                    <?php if (count($categories3) > 0){?>
		                    	<ul>		                    	
							        <?php foreach ($categories3 as $c3){?>
							        	<?php if ($c3['cat_id'] == $c2['id']){?>
			                        		<li>
			                        			<?php if (!empty($province_name) && isset($province_name)){?>
			                        				<a href="<?php echo base_url().$province_name.'/'.url_title(utf8_to_ascii($c3['name'])).'-'.url_title(utf8_to_ascii($c2['name'])).'-'.url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'-'.$c2['id'].'-'.$c3['id'].'.html'?>"><?php echo $c3['name']?></a>
			                        			<?php }else{?>
			                        				<a href="<?php echo base_url().url_title(utf8_to_ascii($c3['name'])).'-'.url_title(utf8_to_ascii($c2['name'])).'-'.url_title(utf8_to_ascii($c1['name'])).'-'.$c1['id'].'-'.$c2['id'].'-'.$c3['id'].'.html'?>"><?php echo $c3['name']?></a>
			                        			<?php }?>
			                        		</li>
			                        	<?php }?>
			                        <?php }?>		                        
		                    	</ul>
		                    <?php }?>
		                </li>		                		                
					<?php }?>					
				<?php $i2++;}?>
                <div class="clear"></div>
            </ul>
        </div>
        <?php if (!empty($list_product)){?>
        <div class="hig">
        	<?php $j=1; foreach ($list_product as $row_prod){?>
        	<li <?php if ($j==5) echo 'style="border-bottom: 0px;"';?>>
        		<a href="<?php echo base_url().url_title(utf8_to_ascii($row_prod['title'])).'-'.$c1['id'].'-'.$row_prod['id'].'.html'?>">
        			<?php if (!empty($row_prod['image'])){?>
        				<img src="<?php echo base_url().'upload/'.$row_prod['image']?>" width="40" height="30" />
        			<?php }else{?>
        				<img src="<?php echo base_url()?>images/sites/no_image.png" width="40" height="30" />
        			<?php }?>
        		</a>
            	<a href="<?php echo base_url().url_title(utf8_to_ascii($row_prod['title'])).'-'.$c1['id'].'-'.$row_prod['id'].'.html'?>"><?php echo $row_prod['title']?></a>
            	<div class="clear"></div>
            </li>
            <?php $j++;}?>        	
        </div>
        <?php }?>
    </div><!--End.col_355-->
<?php if (($i==1) || ($i%2 != 0)){?><div class="width10"></div><?php }?>
<?php if ($i%2 == 0){?><div class="clear"></div><?php }?>
<?php $i++;}?>